<?php namespace Common\Model;
use Hdphp\Model\Model;
class GoodsList extends Model{
	protected $table='goods_list';
	
//	添加货品时自动生成货号
	protected $auto=array(
			array('number','time','function',3,1)
	);
	
	public function store(){
		if($this->create()){
//			p($this->data);exit;
			$gid=Q('get.gid',0,'intval');
			$goods_list=$this->data;
//				p($goods_list);exit;
			foreach($goods_list['combine'] as $v){
				$goodsAttr=new \Common\Model\GoodsAtt;
				$combine[]=$goodsAttr->where("goods_gid={$gid} AND gvalue='$v'")->pluck('gaid');
			}
			$goods_list['combine']=implode(',', $combine);
//			p($combine);exit;
			$this->add($goods_list);
			return true;
		}
			return false;
	}
	
	public function edit(){
		if($this->create()){
			$this->save();
			return true;
		}
			return false;
	}
	
	
}
